package com.sntk.organauthomanager.infrastructure.commit.impl;

import com.sntk.organauthomanager.application.dto.ResponseData;
import com.sntk.organauthomanager.infrastructure.commit.MedicalOrganCommit;
import com.sntk.organauthomanager.infrastructure.utils.RestTemplateUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;

/**
 * @ClassName: MedicalOrganSingletonCommitImpl
 * @author: wgchao
 * @createTime: 2021/3/29 9:03 AM
 * @Description: TODO
 */
@Component
@ConditionalOnProperty(prefix = "env",name = "pattern",havingValue = "singleton")
public class MedicalOrganSingletonCommitImpl implements MedicalOrganCommit {

    @Value("${medical.url}")
    private String url;

    @Override
    public ResponseData searchAllocationOrgans() {
        //TODO resttemplate 访问接口
        ResponseEntity<ResponseData> responseEntity = RestTemplateUtil.get(url + "/sntk/pension/interior/organ", ResponseData.class);
        return responseEntity.getBody();
    }

    @Override
    public ResponseData searchAllOrgansSetting() {
        ResponseEntity<ResponseData> responseEntity = RestTemplateUtil.get(url + "/sntk/system/interior/organsetting/query", ResponseData.class);
        return responseEntity.getBody();
    }
}
